package main

import (
	"context"
	"fmt"
	proto "jaegerDemo/pb"
	"net"

	"google.golang.org/grpc"
)

type GreeterServer struct {
	proto.UnimplementedGreeterServer
}

func (g *GreeterServer) SayHello(ctx context.Context, in *proto.HelloRequest) (*proto.HelloReply, error) {
	out := &proto.HelloReply{
		Message: "hello",
	}
	return out, nil
}

func (g *GreeterServer) SayHi(ctx context.Context, in *proto.HiRequest) (*proto.HiReply, error) {
	out := &proto.HiReply{
		Message: "hi," + in.Name,
	}
	return out, nil
}

func main() {
	address := "localhost:8089"
	lis, err := net.Listen("tcp", address)
	if err != nil {
		panic(err)
	}
	s := grpc.NewServer()
	proto.RegisterGreeterServer(s, &GreeterServer{})
	fmt.Println("监听:", address)
	if err := s.Serve(lis); err != nil {
		panic(err)
	}
}
